package dongshi.daddy.main;

import dongshi.daddy.service.MyHystrixService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class ConsumerWithHystrixMain {
    static Executor executor = Executors.newFixedThreadPool(100);
    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context
                = new ClassPathXmlApplicationContext("consumer-with-hystrix.xml");
        context.start();
        MyHystrixService myHystrixService = (MyHystrixService) context.getBean("myHystrixServiceInConsumerSide");
        while (true) {
/*
            new Thread(() -> {
                System.out.println(myHystrixService.sayHi("熔断哈哈"));
            }).start();
*/
            executor.execute(() -> System.out.println(myHystrixService.sayHi("熔断哈哈")));
            Thread.sleep(50);
        }

//        System.in.read();
    }

}
